#include "tplbinaryexpression.h"

TplBinaryExpression::TplBinaryExpression(QObject *parent)  :
    TplExpression(parent) {
}

TplBinaryExpression::~TplBinaryExpression() {
#ifdef TPL_DEBUG
    qDebug() << "Deleting object TplBinaryExpression: " << this << endl;
#endif
}

/**
    QVariant v(QMetaType::QObjectStar, &im)
 */
void TplBinaryExpression::setContext(QMap<QString, QVariant> *context) {
    this->context = context;

    if(left.canConvert<QObject*>()) {
        QObject* tmp = qvariant_cast<QObject *>(left);
        TplExpression* expr = qobject_cast<TplExpression*>(tmp);
        if(expr) {
            expr->setContext(context);
        }
    }

    if(right.canConvert<QObject*>()) {
        QObject* tmp = qvariant_cast<QObject *>(right);
        TplExpression* expr = qobject_cast<TplExpression*>(tmp);
        if(expr) {
            expr->setContext(context);
        }
    }
}

void TplBinaryExpression::setLeft(const QVariant &left) {
    this->left = left;
}

void TplBinaryExpression::setRight(const QVariant &right) {
    this->right = right;
}
